\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{MXCommon}[2010/08/12 MXCommon package file by Xin Meng]

\RequirePackage{gensymb}
\RequirePackage{multirow}

\RequirePackage{graphicx}
\RequirePackage{overpic}

\RequirePackage{xcolor}
\definecolor{gray}{gray}{0.75}
\definecolor{dark}{gray}{0.55}
\definecolor{orange}{rgb}{1, 0.5, 0.14}
\definecolor{darkorange}{RGB}{196, 105,14}
\definecolor{darkslategray}{rgb}{0.16, 0.294, 0.294}
\definecolor{lightgray}{rgb}{0.9, 0.941, 0.847}
\definecolor{commentorange}{rgb}{1, 0.5, 0.141}
\definecolor{lightblue}{rgb}{0, 1, 1}
\definecolor{darkred}{rgb}{0.75, 0.14, 0.07}
\definecolor{purple}{rgb}{0.521, 0.329, 0.545}
\definecolor{urlblue}{rgb}{0.239, 0.239, 0.714}
\definecolor{darkgreen}{RGB}{4,164,68}
\definecolor{lightred}{rgb}{1,0.7,0.71}
\definecolor{lightgreen}{rgb}{0.64,1,0.71}

\newcommand{\MXCodeFontSize}{\scriptsize}

\DeclareOption{FootnotesizeCode}{
  \renewcommand{\MXCodeFontSize}{\footnotesize}
}

\DeclareOption{TinyCode}{
  \renewcommand{\MXCodeFontSize}{\tiny}
}


\DeclareOption{MXTheme}{
  \definecolor{ThemeColor}{RGB}{41, 54, 121} 
  \definecolor{LinkColor}{RGB}{41, 54, 121}%{27, 75, 229} %blue
  \definecolor{CiteColor}{RGB}{41, 54, 121}%{255, 0, 0}   %red
  \definecolor{URLColor}{RGB}{41, 54, 121}%{27, 75, 229}  %blue
  \definecolor{FileColor}{RGB}{41, 54, 121}%{72, 201, 55} %green
}

\DeclareOption{ExarTheme}{
  \definecolor{ThemeColor}{RGB}{47, 77, 135}
  \definecolor{LinkColor}{RGB}{47, 77, 135} 
  \definecolor{CiteColor}{RGB}{47, 77, 135} 
  \definecolor{URLColor}{RGB}{47, 77, 135}  
  \definecolor{FileColor}{RGB}{47, 77, 135} 
}


\DeclareOption{ForPrint}{       % all black
  \definecolor{ThemeColor}{RGB}{0, 0, 0}
  \definecolor{LinkColor}{RGB}{0, 0, 0} 
  \definecolor{CiteColor}{RGB}{0, 0, 0} 
  \definecolor{URLColor}{RGB}{0, 0, 0}  
  \definecolor{FileColor}{RGB}{0, 0, 0} 
}


\newcommand{\insertfigure}[4][btph]{%
  \begin{figure}[#1]
    \centering
%    \fbox{\includegraphics[width=#1\textwidth]{#3}}
    \includegraphics[width=\textwidth]{#3}
    \caption{#2}\label{#4}
  \end{figure}
}

\newenvironment{mxoverpic}[2][]{%
  \sbox{\z@}{\includegraphics[#1]{#2}}%
  \settodepth{\@tempcnta}{\usebox{\z@}}%
  \settoheight{\@tempcntb}{\usebox{\z@}}%
  \advance\@tempcntb\@tempcnta%
  \settowidth{\@tempcnta}{\usebox{\z@}}%
  \setlength{\@tempdima}{\unitlength}%
\ifdefined\draftworkbook
\ifthenelse{\equal{#1}{}}{\count@=\z@\Gin@gridfalse\setkeys{Gin}{#1,grid,tics=2}}{\count@=\z@\Gin@gridfalse\setkeys{Gin}{grid,tics=2}}% 
\else
\count@=\z@\Gin@gridfalse\setkeys{Gin}{#1}
\fi
%
  \OVP@calc%
%  
  \begin{picture}(\@tempcnta,\@tempcntb)%
    \put(0,0){\makebox(0,0)[bl]{\usebox{\z@}}}%
    \ifGin@grid%
      \put(0,0){\color{gray}\normalfont\fontsize\@viipt\@viiipt\selectfont%
        \grid(\@tempcnta,\@tempcntb)(\count@,\count@)[0,0]}%
    \fi%  
    % reset the graphics parameter
    \let\Gin@outer@scalex\relax
    \let\Gin@outer@scaley\relax
    \let\Gin@angle\relax
    \let\Gin@ewidth\Gin@exclamation
    \let\Gin@eheight\Gin@ewidth
    \def\Gin@scalex{1}
    \let\Gin@scaley\Gin@exclamation
}{% 
  \end{picture}%
}% 


%\newcommand{\overpicgrid}{,grid,tics=2}

\newcommand{\pictext}[5][btph]{
  \begin{figure}[#1]
    \centering
    \begin{mxoverpic}[width=\textwidth]{#3}
      #5
    \end{mxoverpic}
    \caption{#2}\label{#4}
\end{figure}}

\newcommand{\pictextextra}[6][btph]{
  \begin{figure}[#1]
    \centering
    \begin{mxoverpic}[width=\textwidth,#2]{#4}
      #6
    \end{mxoverpic}
    \caption{#3}\label{#5}
\end{figure}}






%% \DeclareOption{draft}{
%%   \renewcommand{\pictext}[6][btph]{
%%     \begin{figure}[#1]
%%       \centering
%%       \begin{mxoverpic}[scale=#2,grid,tics=5]{#4}
%%         #6
%%       \end{mxoverpic}
%%       \caption{#3}\label{#5}
%%   \end{figure}}
%% }


\DeclareOption*{%
  \PackageWarning{MXCommon}{Unknown option `\CurrentOption'}%
}




\ProcessOptions\relax


\RequirePackage[obeyspaces, spaces]{url}
\renewcommand{\UrlFont}{\normalfont} %% Use same style for URL text


\RequirePackage{tabularx}

\RequirePackage[size=footnotesize, skip=2pt]{caption}
\DeclareCaptionFont{ColorCaption}{\color{ThemeColor}\fontseries{b}\selectfont}
\captionsetup{font=ColorCaption}


\RequirePackage{bytefield}[2011/02/09]
\newenvironment{regdef}
               {\setlength{\bitwidth}{.03125\textwidth}
                 \setlength{\byteheight}{1cm}
                 \begin{bytefield}{32}
               }
               { \end{bytefield}}

\newcommand{\colorbitbox}[4][lrtb]{%
  \rlap{\bitbox[#1]{#3}{\color{#2}\rule{\width}{\height}}}%
  \bitbox[#1]{#3}{#4}}

\newcommand{\colorwordbox}[4][lrtb]{%
  \rlap{\wordbox[#1]{#3}{\color{#2}\rule{\width}{\height}}}%
  \wordbox[#1]{#3}{#4}}
 



\RequirePackage{ifthen}
\RequirePackage{xifthen}
\RequirePackage{amsmath}
%\RequirePackage{amsfonts}
%\RequirePackage{amssymb}
\RequirePackage{amsthm}
%\RequirePackage[pdftex]{graphicx}
%\RequirePackage{graphicx}
\RequirePackage{supertabular}
\renewcommand{\arraystretch}{1.2}

\RequirePackage{dirtree}
\DTsetlength{.2em}{1em}{.2em}{.4pt}{.4pt}


\RequirePackage{makeidx}


\RequirePackage{textcomp}

\RequirePackage{listings}
\lstset{%
  upquote=true,%
  indexstyle={\vidx},%
  indexstyle={[2]\pidx},%
  basicstyle={\MXCodeFontSize\tt},%
  stringstyle={\color{orange}},%
  commentstyle={\color{dark}},%
  numbers={left},%
  numberstyle={\tt\color{gray}},%
  columns={flexible},%
  xleftmargin={0.05\textwidth},%
  xrightmargin={0.05\textwidth},%
  showstringspaces=false,%
  frame=none, %
  emphstyle={\color{red}\textsl},%
  %identifierstyle={\color{darkslategray}},
  keywordstyle={\color{blue}},
  keywordstyle={[2]\color{darkred}},
  keywordstyle={[3]\color{purple}},
  keywordstyle={[4]\color{commentorange}},
  escapeinside={/*-}{-*/}%
}

\lstdefinelanguage{metahdl}
{
  morekeywords={always,always_comb,always_ff,always_latch,and,assign,assume,automatic,before,begin,break,buf,bufif0,bufif1,case,casex,casez,cell,chandle,class,cmos,config,context,continue,cross,deassign,default,defparam,design,disable,dist,do,edge,else,end,endcase,endclass,endfunction,endgenerate,endgroup,endinterface,endmodule,endpackage,endprimitive,endprogram,endspecify,endtask,expect,export,final,for,force,forever,function,generate,genvar,highz0,highz1,if,iff,include,initial,inout,input,inside,instance,interface,integer,large,liblist,localparam,module,nand,negedge,net,nmos,nor,noshowcancelled,not,notif0,notif1,null,or,output,parameter,pmos,posedge,primitive,program,pull0,pull1,pulldown,pullup,pulsestyle_onevent,pulsestyle_ondetect,rcmos,realtime,release,return,rnmos,rpmos,rtran,rtranif0,rtranif1,scalared,shortint,shortreal,showcancelled,signed,small,solve,specify,specparam,strong0,strong1,supply0,supply1,task,timeprecision,timeunit,tran,tranif0,tranif1,tri,tri0,tri1,triand,trior,trireg,typedef,unsigned,use,var,vectored,virtual,void,wait,wait_order,wand,weak0,weak1,while,wor,xnor,xor},
  keywordstyle={\bfseries\color{blue}},
  morekeywords={[6]alias,assert,bind,bins,binsof,bit,byte,clocking,const,constraint,cover,covergroup,coverpoint,endclocking,endconfig,endproperty,endsequence,endtable,enum,event,extends,extern,first_match,foreach,fork,forkjoin,ifnone,ignore_bins,illegal_bins,import,incdir,intersect,join,join_any,join_none,library,local,longint,macromodule,matches,medium,modport,new,package,packed,priority,property,protected,pure,rand,randc,randcase,randsequence,ref,repeat,sequence,static,string,struct,super,table,tagged,this,throughout,type,union,unique,wildcard,with,within,},
  keywordstyle={[6]\bfseries\color{darkorange}},
  morekeywords={[7]logic,reg,wire,int,real,time},
  keywordstyle={[7]\bfseries\color{darkgreen}},
  %VP keywords
  morekeywords={[2]\&CombBeg, \&CombEnd, \&Force, \&Regs, \&Wires, \&Ports, \&ModBeg, \&ModEnd, 
    $monitor, $display, $strobe, $write, $cast,
    $typename,
    $left,$right, $low, $high, $increment, $size, $dimensions, $unpacked_dimensions}, %$
  keywordstyle={[2]\bfseries\color{darkred}},
  %MetaHDL keywords
  morekeywords={[3]metahdl,nonport,ff,endff,fsm,endfsm,goto,rawcode,endrawcode},
  keywordstyle={[3]\bfseries\color{purple}},
  %SV directives
  morekeywords={[4]`accelerate,`autoexpand_vectornets,`celldefine,`default_nettype,%
    `define,`else,`elsif,`endcelldefine,`endif,`endprotect,%
    `endprotected,`expand_vectornets,`ifdef,`ifndef,`include,%
    `no_accelerate,`noexpand_vectornets,`noremove_gatenames,%
    `nounconnected_drive,`protect,`protected,`remove_gatenames,%
    `remove_netnames,`resetall,`timescale,`unconnected_drive, %
    `uve_error, `uve_fatal},%
  keywordstyle={[4]\bfseries\color{blue}},
  %MetaHDL directives
  morekeywords={[5]`let, `for, `endfor, `while, `switch, `case, `default, `if},
  keywordstyle={[5]\bfseries\color{purple}},
  alsoletter={\`, \&},%
  sensitive=true,
  morecomment=[l]{//},
  morecomment=[s]{/*}{*/},
  morestring=[b]"  
}

\newcommand{\mhdl}[1]{\lstinline[basicstyle=\tt,language=metahdl]{#1}}
\newcommand{\mhdls}[1]{\lstinline[basicstyle=\tt,language=metahdl]{$#1}} %$
\newcommand{\Mhdl}[1]{\mhdl{#1}}
\newcommand{\Mhdls}[1]{\mhdls{#1}}

\lstnewenvironment{mhdle}[1][]
        {\lstset{language=metahdl, #1}}
        {}                      

\lstnewenvironment{mhdlnle}[1][]
        {\lstset{language=metahdl, numbers=none, frame=none, #1}}
        {}

\newcommand{\mhdlc}{\texttt{mhdlc}}




\RequirePackage{colortbl}

\RequirePackage{fancyhdr}

\RequirePackage[us]{datetime}
\RequirePackage{lscape}

\RequirePackage{marginnote}
\newcommand{\mnote}[1]{\marginnote{\tiny{#1}}}



\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\vidx}[1]{\index{variable!#1@\texttt{#1}}}
\newcommand{\pidx}[1]{\index{parameter!#1@\texttt{#1}}}
\newcommand{\mycomment}[1]{\textcolor{blue}{\footnotesize{[Xin Meng] #1}}}
\newcommand{\tableheader}[1]{{\cellcolor{ThemeColor}\color{white}\bfseries\small #1}}




\RequirePackage{titlesec}
\titleformat{\section}[hang]
            {\color{ThemeColor}\fontseries{bx}\selectfont\Large}
            {\thesection}
            {5mm}{}{\normalfont}
\titleformat{\subsection}[hang]
            {\color{ThemeColor}\fontseries{bx}\selectfont\large}
            {\thesubsection}
            {5mm}{}{\normalfont}
\titleformat{\subsubsection}[hang]
            {\color{ThemeColor}\fontseries{bx}\selectfont}
            {\thesubsubsection}
            {5mm}{}{\normalfont}
\titleformat{\paragraph}[runin]
            {\color{ThemeColor}\fontseries{bx}\selectfont}
            {\theparagraph}
            {5mm}{}{\normalfont}
\titleformat{\subparagraph}[runin]
            {\color{ThemeColor}\fontseries{bx}\selectfont}
            {\thesubparagraph}
            {5mm}{}{\normalfont}




\RequirePackage[pdfnewwindow,unicode,colorlinks,hyperindex]{hyperref}
\hypersetup{
  bookmarksnumbered,
  linkcolor = LinkColor,
  citecolor = CiteColor,
  urlcolor  = URLColor,
  filecolor = FileColor,
  bookmarksopen={false}, 
  pdfstartview={FitH},
}


%\setlength{\hoffset}{-.3in}
%\setlength{\oddsidemargin}{0pt}
\setlength{\marginparwidth}{100pt}
\setlength{\marginparsep}{15pt}
%\setlength{\textwidth}{1.3\textwidth}


%\setlength{\parindent}{0pt}
%\setlength{\parskip}{2mm}

%% \RequirePackage{layouts}
%% \setlayoutscale{0.33}
%% \setparametertextfont{\tiny}
%% \setlabelfont{\tiny}



\makeindex


\newlength{\mmapaddrwidth}
\setlength{\mmapaddrwidth}{.4\textwidth}
\newenvironment{mmaplist}[1][X]
               {\small\ifthenelse{\equal{#1}{X}}{}{\belowpdfbookmark{#1}{#1}\vspace{3ex}\noindent\textcolor{ThemeColor}{\textbf{#1}}\vspace{0ex}}\begin{list}{$\bullet$}{
                     \setlength{\itemindent}{0ex}
                     \setlength{\labelwidth}{\mmapaddrwidth}
                     \setlength{\labelsep}{2ex}
                     \setlength{\leftmargin}{0ex}
                     \addtolength{\leftmargin}{\labelwidth}
                     \addtolength{\leftmargin}{\labelsep}
                     \setlength{\rightmargin}{0cm}
                     \setlength{\listparindent}{0em}
                     \setlength{\topsep}{0ex}
                     \setlength{\partopsep}{0mm}
                     \setlength{\parskip}{0mm}
                     \setlength{\itemsep}{0ex}
                     \setlength{\parsep}{0ex}%{0.5ex plus0.2ex minus0.2ex}
                     \renewcommand{\makelabel}[1]{##1\hfill}
               }}
               {\end{list}}
\newcommand{\mmapitem}[1]{
  \item[\mbox{\makebox[\mmapaddrwidth][l]{#1}}]
}




\newsavebox{\listingbox}
\newlength{\piowidth}\setlength{\piowidth}{7ex}         %input, output, inout
\newlength{\pbitswidth}\setlength{\pbitswidth}{8ex}     %[125:0]
\newlength{\pnamewidth}\setlength{\pnamewidth}{20ex}    %port name
\newlength{\plevelwidth}\setlength{\plevelwidth}{7.5em} %LVCOMS
\newlength{\pfreqwidth}\setlength{\pfreqwidth}{4em}     %100MHz
\newenvironment{portlist}[1][X]
               {\footnotesize\ifthenelse{\equal{#1}{X}}{\vspace{3ex}}{\belowpdfbookmark{#1}{#1}\vspace{3ex}\noindent\textcolor{ThemeColor}{\textbf{#1}}\vspace{0ex}}\begin{list}{$\bullet$}{
                     \setlength{\itemindent}{0ex}
                     \setlength{\labelwidth}{0ex}
                     \addtolength{\labelwidth}{\piowidth}
                     \addtolength{\labelwidth}{\pbitswidth}
                     \addtolength{\labelwidth}{\pnamewidth}
                     \addtolength{\labelwidth}{\plevelwidth}
                     \addtolength{\labelwidth}{\pfreqwidth}
                     \setlength{\labelsep}{2ex}
                     \setlength{\leftmargin}{0ex}
                     \addtolength{\leftmargin}{\labelwidth}
                     \addtolength{\leftmargin}{\labelsep}
                     \setlength{\rightmargin}{0cm}
                     \setlength{\listparindent}{0em}
                     \setlength{\topsep}{0ex}
                     \setlength{\partopsep}{0mm}
                     \setlength{\parskip}{0mm}
                     \setlength{\itemsep}{0ex}
                     \setlength{\parsep}{0ex}%{0.5ex plus0.2ex minus0.2ex}
                     \renewcommand{\makelabel}[1]{##1\hfill}
                   }}
               {\end{list}}

\newcommand{\primaryio}[6][X]{
  \begin{portlist}
  \sbox{\listingbox}{\mhdl{#3}}
\item[\mbox{\makebox[\piowidth][l]{#2}%
    \makebox[\pbitswidth][c]{\ifthenelse{\equal{#1}{X}}{}{[#1]}}%
    \makebox[\pnamewidth][l]{\usebox{\listingbox}}%
    \makebox[\plevelwidth][r]{#4}%
    \makebox[\pfreqwidth][r]{#5}}] #6
  \end{portlist}
}

\newcommand{\primaryioitem}[5][X]{
  \sbox{\listingbox}{\mhdl{#3}}
\item[\mbox{\makebox[\piowidth][r]{#2}%
    \makebox[\pbitswidth][c]{\ifthenelse{\equal{#1}{X}}{}{[#1]}}%
    \makebox[\pnamewidth][l]{\usebox{\listingbox}}%
    \ifthenelse{\lengthtest{\plevelwidth = 0mm}}{}{\makebox[\plevelwidth][r]{#4}}%
    \ifthenelse{\lengthtest{\pfreqwidth = 0mm}}{}{\makebox[\pfreqwidth][r]{#5}}}]
}

%% #1: port width
%% #2: port name
%% #3: frequency
%% #4: level standard
%% #5: pull up/down
%% #6: description
\newcommand{\pinput}[5][X]{\primaryio[#1]{input}{#2}{#3}{#4}{#5}\index{Ports!\mhdl{#2}}}
\newcommand{\poutput}[5][X]{\primaryio[#1]{output}{#2}{#3}{#4}{#5}\index{Ports!\mhdl{#2}}}
\newcommand{\pinout}[5][X]{\primaryio[#1]{inout}{#2}{#3}{#4}{#5}\index{Ports!\mhdl{#2}}}

\newcommand{\pinputitem}[4][X]{\primaryioitem[#1]{input}{#2}{#3}{#4}\index{Ports!\mhdl{#2}}}
\newcommand{\poutputitem}[4][X]{\primaryioitem[#1]{output}{#2}{#3}{#4}\index{Ports!\mhdl{#2}}}
\newcommand{\pinoutitem}[4][X]{\primaryioitem[#1]{inout}{#2}{#3}{#4}\index{Ports!\mhdl{#2}}}








%% \newcommand{\pinput}[6][X]{
%%   {\small
%%     \begin{portlist}
%%     \item[\mbox{\makebox[7ex][l]{input}\makebox[9ex][c]{\ifthenelse{\equal{#1}{X}}{ }{[#1]}}}] 
%%       \mhdl{#2}\hfill\makebox[7.5em][l]{#3}\makebox[4em][c]{#4}\makebox[9ex][r]{#5}\\
%%            {\small #6}
%%     \end{portlist}
%%   }
%% }


\newenvironment{bitslist}
               {\begin{list}{$\bullet$}{
                     \setlength{\labelwidth}{5em}
                     \setlength{\labelsep}{1em}
                     \setlength{\leftmargin}{6em}
                     \setlength{\rightmargin}{0em}
                     \setlength{\listparindent}{0em}
                     \setlength{\topsep}{.8ex}
                     \setlength{\partopsep}{0mm}
                     \setlength{\parskip}{.8ex}
                     \setlength{\itemsep}{1ex}
                     \setlength{\parsep}{0.5ex plus0.2ex minus0.2ex}
                   }}
               {\end{list}}

\newcommand{\bits}[3][X:X]{
  \begin{bitslist}
    \item[{[#1]}\hfill] \textbf{#2}\\#3
  \end{bitslist}
}

\ifdefined\changebarworkbook
\newcommand{\cbinput}[1]{
  \IfFileExists{#1.changebar}
               {\input{#1.changebar}}
               {\input{#1}}
               }

\newcommand{\cbloadglsentries}[2][main]{
  \IfFileExists{#2.changebar}
               {\loadglsentries[#1]{#2.changebar}}
               {\loadglsentries[#1]{#2}}
               }
\else
\newcommand{\cbinput}[1]{\input{#1}}

\newcommand{\cbloadglsentries}[2][main]{\loadglsentries[#1]{#2}}

\fi



%% algorithm2e
\RequirePackage[algochapter,noline,linesnumbered,commentsnumbered,longend,boxed]{algorithm2e}
\SetKw{Break}{break}
\SetAlCapSkip{.5ex}

\newcommand{\AlgoCaptionStyle}[1]{\color{ThemeColor}#1}
\SetAlgoCaptionLayout{AlgoCaptionStyle}

\SetAlCapNameFnt{\bf}

\SetAlFnt{\footnotesize}

\newcommand{\AlgoLineNumberStyle}[1]{\color{gray}#1}
\SetNlSty{AlgoLineNumberStyle}{}{}

\newcommand{\AlgoKeywordStyle}[1]{\color{blue}\textbf{#1}}
\SetKwSty{AlgoKeywordStyle}

\newcommand{\AlgoCommentStyle}[1]{\color{darkgray}\footnotesize#1}
\SetCommentSty{AlgoCommentStyle}

\newcommand{\AlgoArgStyle}[1]{#1}
\SetArgSty{AlgoArgStyle}

\newcommand{\AlgDataStyle}[1]{\color{darkorange}\textsf{#1}}
\SetDataSty{AlgDataStyle}

\newcommand{\AlgFunctionStyle}[1]{\color{darkred}\textsf{\textbf{#1}}}
\SetFuncSty{AlgFunctionStyle}

\DontPrintSemicolon



%% Glossaries
\RequirePackage[toc, numberedsection=autolabel]{glossaries}
\GlsSetXdyCodePage{utf8}
\renewcommand{\glspostdescription}{}

%% For Math 
\theoremstyle{definition}\newtheorem{definition}{Definition}

\theoremstyle{plain}\newtheorem{theorem}{Theorem}



%% ----------------------------------------
%%    My commands
%% ----------------------------------------
\newcommand{\note}{\textbf{NOTE}}
\newcommand{\See}[2][autoref]{\emph{See}
  \ifthenelse{\equal{#1}{autoref}} 
             {\autoref{#2}} 
             {\cite{#2}}}

\newenvironment{reglist}
               {\begin{list}{$\to$}{
                     \setlength{\labelwidth}{8em}
                     \setlength{\labelsep}{1em}
                     \setlength{\itemindent}{0em}
                     \setlength{\leftmargin}{9em}
                     \setlength{\rightmargin}{2em}
                     \setlength{\listparindent}{0em}
                     \setlength{\topsep}{0ex}
                     \setlength{\partopsep}{0mm}
                     \setlength{\parskip}{.8ex}
                     \setlength{\itemsep}{1ex}
                     \setlength{\parsep}{0.5ex plus0.2ex minus0.2ex}
                     %\renewcommand{\makelabel}[1]{##1\hfill}
                   }}
               {\end{list}}


\newglossaryentry{register-type-read-write}{
  name={RW, Read and Write},
  text={RW},
  description={
    One of software register access type. 
    Software can both read/write from/to register.
  }
}
\newcommand{\regrw}[4][0x0]{
  \begin{reglist}
  \item[\mbox{\makebox[3em][l]{\gls{register-type-read-write}}\makebox[5em][c]{[#2]}}] 
    \textbf{#3}\hfill\mhdl{#1}\\
    {\small#4}
  \end{reglist}
}

\newglossaryentry{register-type-read-clear}{
  name={RC, Read only and Clear},
  text={RC},
  description={
    One of software register access type. 
    Software can only read from register, 
    upon read, register will be cleared to \mhdl{0}.
    Software write to register has no effect. 
  }
}
\newcommand{\regrc}[4][0x0]{
  \begin{reglist}
  \item[\mbox{\makebox[3em][l]{\gls{register-type-read-clear}}\makebox[5em][c]{[#2]}}] 
    \textbf{#3}\hfill\mhdl{#1}\\
    {\small#4}
  \end{reglist}
}

\newglossaryentry{register-type-read-only}{
  name={RO, Read Only},
  text={RO},
  description={
    One of software register access type. 
    Software can only read from register,
    write to register has no effect. 
    Register contents are updated by hardware.
  }
}
\newcommand{\regro}[4][0x0]{
  \begin{reglist}
  \item[\mbox{\makebox[3em][l]{\gls{register-type-read-only}}\makebox[5em][c]{[#2]}}] 
    \textbf{#3}\hfill\mhdl{#1}\\
    {\small#4}
  \end{reglist}
}

\newglossaryentry{register-type-read-write-1-clear}{
  name={RW1C, Read only and Write 1 Clear },
  text={RW1C},
  description={
    One of software register access type. 
    Software can read from register,
    write \mhdl{1} to register bit will clear corresponding bit to \mhdl{0}.
    Write \mhdl{0} to register bit has no effect.
  }
}
\newcommand{\regrwc}[4][0x0]{
  \begin{reglist}
  \item[\mbox{\makebox[3em][l]{\gls{register-type-read-write-1-clear}}\makebox[5em][c]{[#2]}}] 
    \textbf{#3}\hfill\mhdl{#1}\\
    {\small#4}
  \end{reglist}
}


\newglossaryentry{register-type-read-write-1-set}{
  name={RW1S, Read only and Write 1 Set },
  text={RW1S},
  description={
    One of software register access type. 
    Software can read from register,
    write \mhdl{1} to register bit will set corresponding bit to \mhdl{1}.
    Write \mhdl{0} to register bit has no effect.
  }
}
\newcommand{\regrws}[4][0x0]{
  \begin{reglist}
  \item[\mbox{\makebox[3em][l]{\gls{register-type-read-write-1-set}}\makebox[5em][c]{[#2]}}] 
    \textbf{#3}\hfill\mhdl{#1}\\
    {\small#4}
  \end{reglist}
}



%% ----------------------------------------
%%   Document property
%% ----------------------------------------
\newcommand{\fixme}[1]{\mnote{\textcolor{red}{\textbf{#1}}}}

\newcommand{\DocTitle}{Document Title}
\newcommand{\DocDescription}{Document Description}
\newcommand{\DocAuthor}{xin.meng@exar.com}
\newcommand{\DocRevision}{0.0}
